SQLiteAggregateFunction<T1,T2,TResult> Class
Generic base class for user-defined aggregate functions with two parameters.
This example illustrates creating and using user-defined function for calculating Average value. Step method is used to accumulate sum of values and iteration count, and Complete method is used to divide sum by iteration count.
public class MyFunction : SQLiteAggregateFunction<long, double> {
private long count;
public MyFunction() : base("Average") {
count = 0;
}
public override void Step(long arg1, SQLiteConnection connection, ref double contextData) {
contextData = contextData + arg1;
count++;
}
public override double Complete(SQLiteConnection connection, double contextData) {
return contextData / count;
}
}
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2